package com.wm.web.controller.system;


import com.wm.common.core.controller.BaseController;
import com.wm.common.core.domain.AjaxResult;
import com.wm.common.core.page.TableDataInfo;
import com.wm.system.domain.CarInfo;
import com.wm.system.service.ICarInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 车辆信息 前端控制器
 * </p>
 *
 * @author hyq
 * @since 2023-09-26 21:47:23
 */
@RestController
@RequestMapping("/system/carInfo")
public class CarInfoController extends BaseController {

    @Autowired
    private ICarInfoService service;

    @ApiOperation("车辆信息分页查询")
    @GetMapping("list")
    public TableDataInfo list(CarInfo carInfo){
        startPage();
        List<CarInfo> carInfoList = service.selectCaeInfoList(carInfo);
        return getDataTable(carInfoList);
    }

    @ApiOperation("车辆信息新增和修改")
    @PostMapping("add")
    public AjaxResult addOrUpdate(@RequestBody CarInfo carInfo) throws Exception{
        service.addOrUpdate(carInfo);
        return AjaxResult.success();
    }

    @ApiOperation("车辆信息单个查询详情")
    @PostMapping("getInfo")
    public AjaxResult getInfo(@RequestBody CarInfo carInfo){
        CarInfo info = service.getInfo(carInfo);
        return AjaxResult.success(info);
    }

}
